package ca.abubakrsagar.breadboardsim;

import javax.swing.JComponent;

/**
 * A superclass for all the components that are to be used on the breadboard. 
 * @author Abubakr
 * @since June 13, 2012
 */
public class Component extends JComponent {

	private boolean inToolBox = true; //Boolean to keep track if the component is in the toolbox.
	private int componentType; //The type of component.
	private int[][] position = { { -1, -1 } }; //The position of the component.

	/**
	 * Creates a new component object.
	 */
	public Component() {

	}

	/**
	 * @return If the component is in the toolbox or not.
	 */
	public boolean isInToolBox() {
		return inToolBox;
	}

	/**
	 * Updates the components state of being in the toolbox.
	 * @param inToolBox If the component is in the toolbox or not.
	 */
	public void setInToolBox(boolean inToolBox) {
		this.inToolBox = inToolBox;
	}

	/**
	 * @return An integer value used to distinguish between various types of components.
	 */
	public int getComponentType() {
		return componentType;
	}

	/**
	 * Sets the components type to be a given value.
	 * @param type The type of component.
	 */
	protected void setComponentType(int type) {
		componentType = type;
	}

	/**
	 * @return The position array of the component.
	 */
	public int[][] getPosition() {
		return position;
	}

	/**
	 * Updates the specified location in the position array to the given value.
	 * @param i The row
	 * @param q The column
	 * @param value The value to be set.
	 */
	public void setPosition(int i, int q, int value) {
		position[i][q] = value;
	}
}
